package com.whfp.coky.ui.task.frag

import android.view.View
import com.whfp.coky.R
import com.whfp.coky.databinding.FragFluorDetectionBinding
import com.whfp.coky.ui.base.BaseFragment
import com.whfp.coky.ui.task.model.TestVoBean
import com.whfp.coky.ui.task.vm.fluor.FluorDetecFragVM
import com.whfp.coky.utils.SpinnerUtils
import com.whfp.coky.widget.clicks


/**
 *
 *
 * created by coky on 2022/3/16
 */
class FluorDetecFrag :BaseFragment<FluorDetecFragVM,FragFluorDetectionBinding>(){

    companion object{
        fun newInstance(): FluorDetecFrag {
            return FluorDetecFrag()
        }
    }

    override fun initView() {
        setOnClickListener(vBinding.tvSex, vBinding.btnScanIdCard,
            vBinding.sbSampleCode,vBinding.btnStartTest,vBinding.btnPrint,vBinding.btnSubmit)

        vBinding.sbInfos.getRightView().clicks {
            vModel.showInfoDetails.value =  !vModel.showInfoDetails.value!!
        }

        SpinnerUtils.buildSpinner(vBinding.spSampleType, resources.getStringArray(R.array.sample_type).toList())

    }

    override fun initData() {

    }

//    加载底部数据
    fun loadBottomDatas(testVoBeans: MutableList<TestVoBean>){

    }



    override fun onClick(view: View) {
        super.onClick(view)
        when(view){
            vBinding.tvSex->vModel.showSexSelect(requireContext())
            vBinding.btnScanIdCard->toast("btnScanIdCard")
            vBinding.sbSampleCode->toast("sbSampleCode")
            vBinding.btnStartTest->toast("btnStartTest${vBinding.spSampleType.text}")
            vBinding.btnPrint->toast("btnPrint")
            vBinding.btnSubmit->toast("btnSubmit")
            else->toast("nothing...")
        }
    }

    fun clearInfos() {
        //姓名
        vBinding.etName.setText("")
        //性别
        vBinding.tvSex.text = ""
        //省份证号
        vBinding.etIdCard.setText("")
        //清空附件信息
//        vBinding.list_data.clear()
//        adapter_fj.setList(list_data)
//        adapter_fj.notifyDataSetChanged()
    }

    //显示定量结果,要联动adapterView的item
    fun changeView(showResult: Boolean) {
        if (showResult){
            //显示定量结果
            vBinding.tvJg.visibility = View.VISIBLE
            vBinding.tvDw.visibility = View.VISIBLE
        }else{
            vBinding.tvJg.visibility = View.VISIBLE
            vBinding.tvDw.visibility = View.VISIBLE
        }
    }
}